package com.ruoyi.project.syl_Sxl.controller;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.syl_Sxl.domain.HisMoney;
import com.ruoyi.project.syl_Sxl.service.IHisMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/syl_Sxl/money")
public class HisMoneyController extends BaseController {

    @Autowired
    private IHisMoneyService iHisMoneyService;
    /**
     * 查询所有项目
     * @param
     * @return
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:money:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisMoney hisMoney)
    {
        startPage();
        List<HisMoney> list = iHisMoneyService.selectAll(hisMoney);
        return getDataTable(list);
    }

    /**
     * 新增
     * @param
     * @return
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:money:add')")
    //@Log(title = "岗位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody HisMoney hisMoney) {
        hisMoney.setCreateBy(SecurityUtils.getUsername());
        return toAjax(iHisMoneyService.insertMoney(hisMoney));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:money:remove')")
    @DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds) {
        return toAjax(iHisMoneyService.deleteByIds(orderIds));
    }

    /**
     * 修改员工
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:money:edit')")
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody HisMoney hisMoney)
    {
        hisMoney.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(iHisMoneyService.updateMoney(hisMoney));
    }

    /**
     * 根据编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:money:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable Long orderId)
    {
        return AjaxResult.success(iHisMoneyService.selectById(orderId));
    }
}
